package com.example.system_backend.service.impl;

import com.example.system_backend.entity.Teeth;
import com.example.system_backend.repository.TeethRepository;
import com.example.system_backend.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.sql.Date;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private TeethRepository teethRepository;

    @Override
    public Integer uploadAndEvaluate(File file, String userEmail, String teethName, Integer teethType, String dtEmail) {
        Long count = teethRepository.count();

        Teeth teeth = new Teeth();
        teeth.setName(teethName);
        teeth.setTime(new Date(System.currentTimeMillis()));
        teeth.setType(teethType);
        teeth.setUserEmail(userEmail);
        teeth.setDtEmail(dtEmail);
        teethRepository.save(teeth);

        return 0;
    }

}
